<template>
	<cl-crud ref="Crud">
		<cl-row>
			<!-- 刷新按钮 -->
			<cl-refresh-btn />
			<!-- 新增按钮 -->
			<cl-add-btn />
			<!-- 删除按钮 -->
			<cl-multi-delete-btn />
			<cl-flex1 />
			<!-- 关键字搜索 -->
			<cl-search-key />
		</cl-row>

		<cl-row>
			<!-- 数据表格 -->
			<cl-table ref="Table" />
		</cl-row>

		<cl-row>
			<cl-flex1 />
			<!-- 分页控件 -->
			<cl-pagination />
		</cl-row>

		<!-- 新增、编辑 -->
		<cl-upsert ref="Upsert" />
	</cl-crud>
</template>

<script lang="ts" name="demo-player_data" setup>
import { useCrud, useTable, useUpsert } from "@cool-vue/crud";
import { useCool } from "/@/cool";

const { service } = useCool();

// cl-upsert
const Upsert = useUpsert({
	items: [
		{ prop: "paddleId", label: "桨的编号", required: true, component: { name: "el-input" } },
		{ prop: "shipId", label: "船的编号", required: true, component: { name: "el-input" } },
		{
			prop: "playerName",
			label: "运动员名字",
			required: true,
			component: { name: "el-input" }
		},
		{ prop: "gender", label: "性别", required: true, component: { name: "el-input" } },
		{ prop: "verticalPower", label: "桨力", required: true, component: { name: "el-input" } },
		{
			prop: "horizontalPower",
			label: "桨水平力",
			required: true,
			component: { name: "el-input" }
		},
		{ prop: "pressure", label: "脚踏板力", required: true, component: { name: "el-input" } },
		{ prop: "velocity", label: "滑座速度", required: true, component: { name: "el-input" } },
		{ prop: "paddleAngle", label: "浆角", required: true, component: { name: "el-input" } },
		{ prop: "outAngle", label: "出水角", required: true, component: { name: "el-input" } },
		{ prop: "InAngle", label: "入水角", required: true, component: { name: "el-input" } },
		{ prop: "frequency", label: "浆频", required: true, component: { name: "el-input" } }
	]
});

// cl-table
const Table = useTable({
	columns: [
		{ type: "selection" },
		{ prop: "id", label: "ID" },
		{ prop: "paddleId", label: "桨的编号" },
		{ prop: "shipId", label: "船的编号" },
		{ prop: "playerName", label: "运动员名字" },
		{ prop: "gender", label: "性别" },
		{ prop: "verticalPower", label: "桨力" },
		{ prop: "horizontalPower", label: "桨水平力" },
		{ prop: "pressure", label: "脚踏板力" },
		{ prop: "velocity", label: "滑座速度" },
		{ prop: "paddleAngle", label: "浆角" },
		{ prop: "outAngle", label: "出水角" },
		{ prop: "InAngle", label: "入水角" },
		{ prop: "frequency", label: "浆频" },
		{ prop: "createTime", label: "创建时间", sortable: "desc", width: 160 },
		// { prop: "updateTime", label: "更新时间", sortable: "custom", width: 160 },
		{ type: "op", buttons: ["edit", "delete"] }
	]
});

// cl-crud
const Crud = useCrud(
	{
		service: service.demo.player_data
	},
	(app) => {
		app.refresh();
	}
);
</script>
